package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.dto.SysCompanyDTO;
import com.nineclock.system.dto.SysCompanyUserDTO;
import com.nineclock.system.dto.SysUserDTO;
import com.nineclock.system.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@RestController
public class TestController {

    @Autowired
    TestService testService;

    @GetMapping("/company/list/{userId}")
    public Result<List<SysCompanyDTO>> queryCompanyListByUserId(@PathVariable("userId") Long userId) {

        List<SysCompanyDTO> companyDTOList = testService.queryCompanyListByUserId(userId);
        return Result.success(companyDTOList);
    }

    @GetMapping("/companyUser/query")
    public Result<List<SysCompanyUserDTO>> queryCompanyUser(Long companyId, Long userId) {
        List<SysCompanyUserDTO> companyUserDTOList = testService.queryCompanyUser(companyId, userId);
        return Result.success(companyUserDTOList);
    }

    @GetMapping("/user/query")
    public Result<SysUserDTO> queryUser(String username) {
        SysUserDTO sysUserDTO = testService.queryUser(username);
        return Result.success(sysUserDTO);
    }
}
